<th:block>
    package [[${basePackage}]].mng.controller.[[${beanModel}]];
    import com.alibaba.fastjson.JSON;
    import com.alibaba.fastjson.JSONObject;
    import com.github.pagehelper.PageInfo;
    import com.google.common.base.Splitter;
    import com.google.common.collect.Maps;
    import [[${basePackage}]].common.bean.[[${beanModel}]].[[${beanName}]];
    import [[${basePackage}]].common.exception.ServiceException;
    import [[${basePackage}]].common.service.DwzPage;
    import [[${basePackage}]].common.bean.[[${beanModel}]].[[${beanName}]]Service;
    import [[${basePackage}]].common.utils.tool.StringTool;
    import [[${basePackage}]].mng.controller.BaseAction;
    import [[${basePackage}]].mng.domain.DwzResponse;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Controller;
    import org.springframework.ui.Model;
    import org.springframework.web.bind.annotation.GetMapping;
    import org.springframework.web.bind.annotation.PostMapping;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.ResponseBody;
    import tk.mybatis.mapper.entity.Example;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.util.Date;
    import java.util.List;
    import java.util.Map;

    /**
    * @Author:[[${SysAuthor}]]
    * @Date:[[${nowTime}]]
    * @Description:[[${beanDesc}]]
    */
    @Controller
    @RequestMapping("[[${actionBaseUrl}]]")
    public class [[${beanName}]]Controller extends BaseAction {

    @Autowired
    [[${beanName}]]Service [[${beanNameL}]]Service;
</th:block>
<th:block>
    /**
    * [[${beanDesc}]]
    *
    * @return
    */
    @RequestMapping(value = "")
    public String execute(HttpServletRequest _request, Model model) {
    // 字段查询条件
    Map< String, Object > objects = Maps.newHashMap();
    extraParams(objects, _request, [[${beanName}]].class);
    modelParm(objects, model);
    // 分页查询条件
    int pageNum = StringTool.parseInteger(_request.getParameter("pageNum"), 1);
    int numPerPage = StringTool.parseInteger(_request.getParameter("numPerPage"), SystemConstants.PAGE_LIMIT_20);
    // 数据查询组装
    Example example = buildExample(objects, model, [[${beanName}]].class);
    PageInfo< [[${beanName}]] > pageRtn = [[${beanNameL}]]Service.findPage(pageNum, numPerPage, example);
    model.addAttribute("page", new DwzPage(pageNum, numPerPage, pageRtn.getTotal()));
    model.addAttribute("records", pageRtn.getList());
    return render("[[${actionBaseUrl}]]/index");
    }
</th:block>
<th:block>
    /**
    * [[${beanDesc}]]_新增
    */
    @GetMapping(value = "/add")
    public String add_get() {
    return render("[[${actionBaseUrl}]]/add");
    }

    @PostMapping(value = "/add")
    @ResponseBody
    public DwzResponse add_post(HttpServletRequest _request, [[${beanName}]] [[${beanNameL}]]) {
    try {
    checkVerifyCert(_request);
    } catch (ServiceException e) {
    return new DwzResponse("300", e.getMessage());
    }

    // 添加[[${beanDesc}]]
    try {
    [[${beanNameL}]].setDataStatus(DataStatusEnum.OPEN.getCode());
    [[${beanNameL}]].setCreateTime(new Date());
    [[${beanNameL}]].setModifyTime(new Date());
    [[${beanNameL}]]Service.save([[${beanNameL}]]);
    return new DwzResponse("200", "[[${beanDesc}]]添加成功!!!", "closeCurrent");
    } catch (Exception e) {
    e.printStackTrace();
    return new DwzResponse("300", "[[${beanDesc}]]添加失败:" + e.getMessage() + "!!!");
    }
    }
</th:block>
<th:block>
    /**
    * [[${beanDesc}]]_更新
    */
    @GetMapping(value = "/edit")
    public String edti_get(Model model, Long id) {
    [[${beanName}]] entity = [[${beanNameL}]]Service.findById(id);
    model.addAttribute("entity", entity);
    return render("[[${actionBaseUrl}]]/edit");
    }

    @PostMapping(value = "/edit")
    @ResponseBody
    public DwzResponse edit_post(HttpServletRequest _request, [[${beanName}]] [[${beanNameL}]]) {
    try {
    checkVerifyCert(_request);
    } catch (ServiceException e) {
    return new DwzResponse("300", e.getMessage());
    }
    if ([[${beanNameL}]] == null || [[${beanNameL}]].getId() == null) {
    return new DwzResponse("300", "参数异常！");
    }
    try {
    [[${beanNameL}]].setModifyTime(new Date());
    [[${beanNameL}]]Service.update([[${beanNameL}]]);
    return new DwzResponse("200", "[[${beanDesc}]]修改成功!!!", "closeCurrent");
    } catch (Exception e) {
    e.printStackTrace();
    return new DwzResponse("300", "[[${beanDesc}]]修改失败:" + e.getMessage());
    }
    }
</th:block>
<th:block>
    /**
    * [[${beanDesc}]]_删除
    *
    * @param id
    * @
    */
    @PostMapping(value = "/del")
    @ResponseBody
    public DwzResponse del_post(HttpServletRequest _request, Long id) {
    try {
    checkVerifyCert(_request);
    } catch (ServiceException e) {
    return new DwzResponse("300", e.getMessage());
    }
    if (id == null || 0 >= id.intValue()) {
    return new DwzResponse("300", "参数ID为空！");
    }
    [[${beanName}]] old = [[${beanNameL}]]Service.findById(id);
    if (old == null) {
    return new DwzResponse("300", "参数[id]信息异常！");
    }
    try {
    [[${beanNameL}]]Service.deleteById(id);
    return new DwzResponse("200", "[[${beanDesc}]]删除成功!!!");
    } catch (Exception e) {
    e.printStackTrace();
    return new DwzResponse("300", "[[${beanDesc}]]删除失败:" + e.getMessage());
    }
    }
</th:block>
<th:block>
    /**
    * [[${beanDesc}]]_详情
    *
    * @return
    */
    @GetMapping(value = "/detail")
    public String detail(HttpServletResponse _response, Model model, Long id) {
    [[${beanName}]] [[${beanNameL}]] = [[${beanNameL}]]Service.findById(id);
    model.addAttribute("entity", [[${beanNameL}]]);
    return render("[[${actionBaseUrl}]]/detail");
    }
</th:block>
<th:block>
    }
</th:block>


